#include "PhysicsBall.h"

void PhysicsBall::CreateGeometry()
{
	// this is going to be a cube of radius 1
	GameGeometry* ball1 = new D3DXSphere(radius);
	ball1->SetColor(BallColour.r,BallColour.g, BallColour.b);
	Geometry.push_back(ball1);
}

void PhysicsBall::CreatePhysicsObject()
{
	// now add a Havok equivilent
	const hkReal sphereMass = 20.0f;
	//const hkReal sphereMass = 1;
	havokShape = new hkpSphereShape( radius );

	hkpMassProperties massProperties;
	hkpInertiaTensorComputer::computeSphereVolumeMassProperties(radius, sphereMass, massProperties);

	bodyInfo.m_mass = massProperties.m_mass;
	bodyInfo.m_restitution = 0.4;
	bodyInfo.m_friction = 0.5;
	bodyInfo.m_centerOfMass  = massProperties.m_centerOfMass;
	bodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
	bodyInfo.m_shape = havokShape;
	bodyInfo.m_position = hkVector4(Position.x,Position.y,Position.z,0);
	bodyInfo.m_allowedPenetrationDepth = 0.0f;

	bodyInfo.m_motionType  = hkpMotion::MOTION_SPHERE_INERTIA;


	havokRigidBody = new hkpRigidBody( bodyInfo );
}
